package com.ustcinfo.ishare.bdp.hbase;

import java.util.LinkedList;
import java.util.List;

import org.apache.hadoop.hbase.client.Put;

public class Hbase_writer {

	public static void main(String[] args){

		List<Put> list=new LinkedList<Put>();

		Put put = new Put("0001".getBytes());  //row key
		put.addColumn("F1".getBytes(), "task_id".getBytes(), "1".getBytes());  //簇 列 值
		put.addColumn("F1".getBytes(), "create_time".getBytes(), "2018-3-3 10:10:10".getBytes());
		put.addColumn("F1".getBytes(), "start_time".getBytes(), "2018-3-3 10:10:10".getBytes());
		put.addColumn("F1".getBytes(), "out_filter_number".getBytes(), "100".getBytes());
		put.addColumn("F1".getBytes(), "from_run_param".getBytes(), "param".getBytes());

		put.addColumn("F2".getBytes(), "current_retry_times".getBytes(), "2018-3-3 10:10:10".getBytes());
		put.addColumn("F2".getBytes(), "retry_flag".getBytes(), "flag".getBytes());
		put.addColumn("F2".getBytes(), "parent_task_id".getBytes(), "0010".getBytes());
		put.addColumn("F2".getBytes(), "end_time".getBytes(), "2018-3-3 10:10:10".getBytes());
		put.addColumn("F2".getBytes(), "kill_time".getBytes(), "2018-3-3 10:10:10".getBytes());
		put.addColumn("F2".getBytes(), "failure_time".getBytes(), "2018-3-3 10:10:10".getBytes());

		list.add(put); 

		if(HBaseMetaDao.tableExist("BD_TEST")){
			HBaseMetaDao.deleteTable("BD_BTEST");
			System.out.println("already delete...");
		}

		HBaseMetaDao.createTable("BD_TEST","F1","F2");

		if(HBaseMetaDao.tableExist("BD_TEST")){
			System.out.println("BD_TEST create success...");

			HBaseOperationDao.putList("BD_TEST",list);
		}
	}
}
